#ifndef VOICEPLAYER_H
#define VOICEPLAYER_H

#include <QtCore>
#include <QtMultimedia>

struct AudioItem {
    QAudioOutput *audio;
    QByteArray *cache;
    QBuffer *buffer;
    AudioItem() {
        audio = nullptr;
        cache = nullptr;
        buffer = nullptr;
    }
};

class VoicePlayer : public QThread
{
    Q_OBJECT
public:
    VoicePlayer();
    ~VoicePlayer();
    void playBuffer(const QByteArray &data);

Q_SIGNALS:
    void doPlayDone();

private Q_SLOTS:
    void onInit();
    void onExitThread();
    void onPlay(QByteArray data);

private:
    int index;
    QList<AudioItem> audios_;
};

#endif // VOICEPLAYER_H
